package com.wan.personnel2.util;

import com.baomidou.mybatisplus.extension.api.R;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Utils {
    public static String md5(String password) throws NoSuchAlgorithmException {
        //生成应该md5加密器
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(password.getBytes());
            return new BigInteger(1,md.digest()).toString(16);
        } catch (NoSuchAlgorithmException e){
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 重复加密10此
     * @param password
     * @return
     */
    public static String repeat(String password,String userName) throws NoSuchAlgorithmException {
        for (int i = 0; i < 10;i++){
            password = md5(password+userName);
        }
        return password;
    }

}
